package com.heihei.combine.applist;

import com.heihei.combine.util.DirFlagUtil;
import com.heihei.constant.MessageConstant;
import com.heihei.util.FileUtilF;
import com.heihei.videopreview.MergeVideoPreviewStart;

import java.io.File;
import java.io.IOException;

public class VideoPreview {

    public static void startMergeVideoPreviewStart() throws IOException, InterruptedException {
        //初始化SB
        MergeVideoPreviewStart.SB = new StringBuffer();
        System.out.println("请输入源目录：");
        File validSrcDirOrFile = FileUtilF.getValidSrcPath();
        Integer flag = DirFlagUtil.getFlag();
        if(flag == 1) {
            MergeVideoPreviewStart.handleCurrentDirOrFile(validSrcDirOrFile);
        } else if(flag == 2) {
            if(validSrcDirOrFile.isDirectory()) {
                File[] listFiles = validSrcDirOrFile.listFiles();
                for (File child : listFiles) {
                    if((child.isFile() && FileUtilF.isVideo(child)) || child.isDirectory()) {
                        MergeVideoPreviewStart.handleCurrentDirOrFile(child);
                    }
                }
            } else {
                System.out.println(MessageConstant.ILLEGAL_FILE_STYLE);
            }
        } else {
            System.out.println(MessageConstant.PARAM_ILLEGAL);
        }
    }
}